package com.ccg.controller;

import com.ccg.entity.Message;
import com.ccg.entity.Room;
import com.ccg.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("/admin/room")
@Controller
public class RoomController {

    @Autowired
    RoomService roomService;

    //根据房间类型以及状态获取所有房间
    @RequestMapping("/getRoomBtStatusRt_id")
    @ResponseBody
    public Message getRoomByStatusRt_id(@RequestBody Room room){
        List<Room> rooms = roomService.findRoomByStatus_Type(room);
        return new Message(0,"获取数据成功",rooms);
    }
    //修改房间的房间类型
    @RequestMapping("/updateRoomType")
    @ResponseBody
    public Message updateRoomType(@RequestBody Room room){
        return roomService.updateTypeById(room);
    }
    //添加一个房间
    @RequestMapping("/addRoom")
    @ResponseBody
    public Message addRoom(@RequestBody Room room){
        return roomService.addRoom(room);
    }
    //修改房间的床数
    @RequestMapping("/updateBedByRoom")
    @ResponseBody
    public Message updateBedByRoom(@RequestBody Room room){
        return roomService.updateBedByRoom(room);
    }
    //根据房间类型查找该类型的所有房间
    @RequestMapping("/findRoomByType")
    @ResponseBody
    public Message findRoomByType(int rt_id){
        return new Message(0,"查找成功",roomService.findRoomByType(rt_id));
    }

//    //查找所有房间
//    @RequestMapping("/findAllRoom")
//    @ResponseBody
//    public Message findAllRoom(){
//        return new Message(0,"查找成功",roomService.findAllRoom());
//    }
}
